/**
 * Created by yjj on 2017/4/25.
 */
import axios from 'axios';
import {API_NEW_VERSION, API_VERSION} from '../api';
var qs = require('qs');

const SHORT_TASKS_ALL = API_NEW_VERSION + 'short_tasks/all';

/**
 * 查询接货任务列表不分页
 */
export const shortTasksNoPage = params => {
  return axios.get(SHORT_TASKS_ALL, {params: params});
};

/**
 * 查询接货任务列表
 */
export const shortTasks = params => {
  return axios.get(API_NEW_VERSION + `short_tasks`, {params: params});
};

/**
 * 修改接货任务
 */
export const modifyShortTasks = (ids, params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks', {ids: ids, params: params});
};

export const addAndIssuedShortTask = (taskType, filters, ids, params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks_add_and_issued/' + taskType, {filters: filters, ids: ids, params: params});
};

export const removeShortTask = (vehicleId, filters, ids, params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks_remove/' + vehicleId, {filters: filters, ids: ids, params: params});
};
// 客服取消分派给司机的任务
export const cancelShortTask = (params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks_cancel', params);
};
// 接货入库中取消分派给临时司机任务
export const cancelTemporaryDriverTask = params => {
  return axios.post(API_NEW_VERSION + 'short_tasks_cancel/temporary_driver', qs.stringify(params));
};

export const issuedAndPriceShortTask = (vehicleId, filters, ids, params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks_issued_and_price/' + vehicleId, {filters: filters, ids: ids, params: params});
};

export const modifyShortTask = (id, params) => {
  return axios.post(API_NEW_VERSION + 'short_tasks/' + id, params);
};

export const splitShortTask = (id, data) => {
  return axios.post(API_NEW_VERSION + 'short_tasks/' + id + '/split', data);
};

export const cancleSplitShortTask = (id) => {
  return axios.delete(API_NEW_VERSION + 'short_tasks/' + id + '/cancel_split');
};

export const isCancleSplitShortTask = (id) => {
  return axios.get(API_NEW_VERSION + 'short_tasks/' + id + '/cancel_split');
};

/**
 * 根据条件查询司机信息driver_infos
 */
export const searchDriverInfos = params => {
  return axios.get(API_VERSION + `driver_infos`, {params: params});
};

/**
 * 根据order的Id查询
 */
export const getOrderTableData = params => {
  return axios.get(API_NEW_VERSION + 'short_task_order_info', {params: params});
};

/**
 * 查询接货任务列表
 */
export const shortTasksForTrace = params => {
  return axios.get(API_NEW_VERSION + `short_tasks_trace`, {params: params});
};

/**
 * 整车确认/接货确认saveShortTaskTraceEnormity
 */
export const affirmCargo = params => {
  return axios.post(API_NEW_VERSION + `short_task_trace/affirm_associate?shortTaskIds=` + params.shortTaskIds);
};

/**
 * 接货异常确认
 */
export const saveShortTaskTraceEnormity = (token, params) => {
  return axios.post(API_NEW_VERSION + `short_task_trace_enormity`, params);
};

/**
 * 查询接货任务-历史记录列表
 */
export const searchShortTaskTraceHs = params => {
  return axios.get(API_NEW_VERSION + `short_tasks_trace/detail_hs`, {params: params});
};

/**
 * 按条件导出接货任务-历史记录列表
 * @param params
 */
export const exportTaskHistory = params => {
  return axios.get(API_NEW_VERSION + `export_short_tasks_trace/detail_hs`, {params: params});
};

/**
 * 取消接货确认
 */
export const cancelAffirmCargo = params => {
  return axios.post(API_NEW_VERSION + `short_task_trace_affirm/cancel?shortTaskIds=` + params.shortTaskIds);
};

export const shortTasksSendRegionAndNum = params => {
  return axios.get(API_NEW_VERSION + `short_tasks_send_region_and_num`, {params: params});
};

export const shortTasksShipmentsRegionAndNum = params => {
  return axios.get(API_NEW_VERSION + `short_tasks_shipments_region_and_num`, {params: params});
};
